﻿/* Copyright (C) Siemens AG, 2012. All Rights Reserved.
 * Author: Roland Eckl, Corporate Technology
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using RVM;


namespace RvmShared
{
    /// <summary>
    /// Some parent viewmodel, consists of a further RemotableViewModel
    /// as well as an traditional viewmodel (simply implementing INotifyPropertyChanged).
    /// </summary>
    public class ViewModelParent : RemotableViewModel
    {
        // TODO: No constructors if to be explictitely exported via Exporter. -> Activator in Importer must not assume any parameterized constructor.

        /// <summary>
        /// Constructor registers ViewModel at registry.
        /// All registered ViewModels are automatically exported.
        /// </summary>
        public ViewModelParent(bool register)
        {
            if (register)
                ExportViewModel(GetType().ToString());
        }

        /// <summary>
        /// Default constructor, explicit export required.
        /// </summary>
        public ViewModelParent() : this(false) {}

        /// <summary>
        /// Simple sample for a RemotableViewModel.
        /// </summary>
        public SimpleViewModel Simple
        {
            get { return GetValue("Simple") as SimpleViewModel; }
            set { SetValue("Simple", value); }
        }

        /// <summary>
        /// Traditional view model implementing INotifyPropertyChanged interface.
        /// </summary>
        public TraditionalViewModel Traditional
        {
            get { return GetValue("Traditional") as TraditionalViewModel; }
            set { SetValue("Traditional", value); }
        }
    }
}
